package com.jeecms.cms.entity.assist.base;

import com.jeecms.cms.entity.assist.Branch;
import com.jeecms.cms.entity.assist.CmsEnterprise;
import com.jeecms.core.entity.CmsSite;

import java.io.Serializable;
import java.util.Set;

/**
 * This is an object that contains data related to the jc_branch table.
 * Do not modify this class because it will be overwritten if the configuration file
 * related to this class is modified.
 *
 * @hibernate.class
 *  table="jc_branch"
 */

public abstract class BaseBranch implements Serializable {

    public static String REF = "CmsUser";
    public static String PROP_RGT = "rgt";
    public static String PROP_SITE = "site";
    public static String PROP_LFT = "lft";
    public static String PROP_PARENT = "parent";
    public static String PROP_REMARKS = "remarks";
    public static String PROP_PRIORITY = "priority";
    public static String PROP_NAME = "name";
    public static String PROP_ID = "id";

    protected void initialize () {}

    private int hashCode = Integer.MIN_VALUE;

    // primary key
    private java.lang.Integer id;

    // fields
    private java.lang.String name;
    private java.lang.Integer lft;
    private java.lang.Integer rgt;
    private java.lang.Integer priority;
    private java.lang.String remarks;

    // many to one
    private com.jeecms.core.entity.CmsSite site;
    private Branch parent;

    // collections
    private Set<Branch> child;
    private Set<CmsEnterprise> enterprises;

    public BaseBranch() {
        initialize();
    }

    public BaseBranch(Integer id) {
        this.setId(id);
        initialize();
    }

    public BaseBranch(Integer id, String name, Integer lft, Integer rgt, Integer priority, String remarks, CmsSite site) {
        this.setId(id);
        this.setName(name);
        this.setLft(lft);
        this.setRgt(rgt);
        this.setPriority(priority);
        this.setRemarks(remarks);
        this.setSite(site);
        initialize();
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
        this.hashCode = Integer.MIN_VALUE;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getLft() {
        return lft;
    }

    public void setLft(Integer lft) {
        this.lft = lft;
    }

    public Integer getRgt() {
        return rgt;
    }

    public void setRgt(Integer rgt) {
        this.rgt = rgt;
    }

    public Integer getPriority() {
        return priority;
    }

    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    public CmsSite getSite() {
        return site;
    }

    public void setSite(CmsSite site) {
        this.site = site;
    }

    public Branch getParent() {
        return parent;
    }

    public void setParent(Branch parent) {
        this.parent = parent;
    }

    public Set<Branch> getChild() {
        return child;
    }

    public void setChild(Set<Branch> child) {
        this.child = child;
    }

    public Set<CmsEnterprise> getEnterprises() {
        return enterprises;
    }

    public void setEnterprises(Set<CmsEnterprise> enterprises) {
        this.enterprises = enterprises;
    }

    public boolean equals (Object obj) {
        if (null == obj) return false;
        if (!(obj instanceof Branch)) return false;
        else {
            Branch branch = (Branch) obj;
            if (null == this.getId() || null == branch.getId()) return false;
            else return (this.getId().equals(branch.getId()));
        }
    }

    public int hashCode () {
        if (Integer.MIN_VALUE == this.hashCode) {
            if (null == this.getId()) return super.hashCode();
            else {
                String hashStr = this.getClass().getName() + ":" + this.getId().hashCode();
                this.hashCode = hashStr.hashCode();
            }
        }
        return this.hashCode;
    }


    public String toString () {
        return super.toString();
    }
}
